/**
 * @file Define the partner controller
 * 
 * @author Steve Gao<gaofu@parllay.com>
 */
const WebBaseController = require('./web-base-controller');

const {SystemServices}  = require('../../constants');

/**
 * The partner controller
 * 
 * @class PartnerController
 * @extends {WebBaseController}
 */
class PartnerController extends WebBaseController {
    
    get name() {
        return "PartnerController";
    }

    get handlersPath() {
        return "partner";
    }

    get partnerService() {
        if (!this._partnerService) {
            this._partnerService = this.getSystemService(SystemServices.PARTNER_SERVICE);
        }

        return this._partnerService;
    }

    /**
     * Wrap the getPartners method of PartnerService
     * 
     * @param {Object} params 
     * @param {Function} parentCallback 
     * 
     * @memberof PartnerController
     */
    getPartners(params, parentCallback) {
        this.partnerService.getPartners(params, (result) => {
            parentCallback(result);
        });
    }

    /**
     * Wrap the getPartnerTVAppVersions of PartnerService
     * 
     * @param {Object} params 
     * @param {Function} parentCallback 
     * 
     * @memberof PartnerController
     */
    getPartnerTVAppVersions(params, parentCallback) {
        this.partnerService.getPartnerTVAppVersions(params, (result) => {
            parentCallback(result);
        });
    }

    /**
     * Wrap the createNewTVAppVersion of PartnerService
     * 
     * @param {Object} data 
     * @param {Function} parentCallback 
     * 
     * @memberof PartnerController
     */
    createNewTVAppVersion(data, parentCallback) {
        this.partnerService.createNewTVAppVersion(data, (result) => {
            parentCallback(result);
        });
    }

    /**
     * Wrap updateTVAppVersion of PartnerController 
     * 
     * @param {Object} data 
     * @param {Function} parentCallback 
     * 
     * @memberof PartnerController
     */
    updateTVAppVersion(data, parentCallback) {
        this.partnerService.updateTVAppVersion(data, (result) => {
            parentCallback(result);
        });
    }
}

exports.PartnerController = PartnerController;